//
//  AchievementLayer.h
//  ATM Killer
//
//  Created by USoft on 7/24/14.
//
//

#ifndef ACHIEVEMENT_LAYER_H
#define ACHIEVEMENT_LAYER_H
#include "AbstractLayer.h"
using namespace extension;

class AchievementLayer: public AbstractLayer{
    UG_PROPERTY_FULL(GameModel*, gameModel, GameModel);
    UG_PROPERTY_FULL(Layer*, boardLayer, BoardLayer);
    UG_PROPERTY_FULL(Layer*, popUpLayer, PopUpLayer);
    UG_PROPERTY_FULL(Layer*, cardsLayer, CardsLayer);
    UG_PROPERTY_FULL(__Array*, pageButtons, PageButtons);
    UG_PROPERTY_FULL(Label*, achievementTitle, AchievementTitle);
    UG_PROPERTY_FULL(Label*, currentMoneyLabel, CurrentMoneyLabel);
    UG_PROPERTY_FULL(Label*, currentNameLabel, CurrentName);
    UG_PROPERTY_FULL(Label*, currentDescLabel, CurrentDesc);
    UG_PROPERTY_FULL(Label*, currentEffectLabel, CurrentEffectLabel);
    UG_PROPERTY_FULL(Label*, showCostLabel, ShowCostLabel);
    UG_PROPERTY_FULL(MenuItemSprite*, showButton, ShowButton);
    UG_PROPERTY_FULL(MenuItemSprite*, okButton, OkButton);
    UG_PROPERTY_FULL(MenuItemSprite*, cancelButton, CancelButton);
    UG_PROPERTY_FULL(int, achievementEffectType, AchievementEffectType);
    
private:
    int cardChoice;
    int cardDirection = NUM_CARDS_HALT;
    bool swipe = false;
    int contentOffsetSpeed;
    float finishContentOffset;
    cocos2d::Point pointSwipe;
    float timeOfSwipe = 0.0f;
    
    bool availablePopUp;
    int currentChoosenPage;
    int currentAchievementId;
    bool isPopUpShow;
    UGLayerColor* grayLayer;
    ScrollView* boardContent;
    Face* achievementBoard;
    Face* currentAchievementFace;
    Face* popUpFace;
    virtual void onEnter();
    virtual void onExit();
    void touchesRegister();
    void onTouchesBegan(const std::vector<Touch*>& touches, Event* event);
    void onTouchesMoved(const std::vector<Touch*>& touches, Event* event);
    void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
    
    void initialize();
    void createLayers();
    void createLayersContent();
    void createPageButtons();
    void loadPopUp();
    void cancelPopUp(Ref* sender);
    void showInfoPopUp(Ref* sender);
    void onButtonClick(Ref* sender);
    void onCloseAchievementBoard(Ref* sender);
public:
    AchievementLayer();
    ~AchievementLayer();
    virtual void update(float dt);
    CREATE_FUNC(AchievementLayer);
};

#endif /* defined(__ATM_Killer__AchievementLayer__) */

